package com.scfw.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by sehuaqi on 2017/7/3.
 * 测试Redis好不好用。
 */
@RestController
@RequestMapping(value = "/redis")
public class RedisController {

    @Autowired
    private RedisDao redisDao;

    @RequestMapping(value = "/setVal", method = RequestMethod.POST)
    public void setVal(String key, String val) {
        redisDao.setKey(key, val);
    }

    @RequestMapping(value = "/setValTime", method = RequestMethod.POST)
    public void setValTime(String key, String val, Long time) {
        redisDao.setKey(key, val, time);
    }

    @RequestMapping(value = "/getVal/{key}", method = RequestMethod.GET)
    public String getVal(@PathVariable String key) {
        return redisDao.getKey(key);
    }
}
